A {fUnderline}reentrant{f} program is one which does not alter in the course of
execution; in other words, it consists entirely of {fUnderline}pure{f} (read-only)
code. Reentrancy is important whenever asynchronous execution is possible;
for example, a nonreentrant program may not be safe to call from a signal
handler. In systems with multiple threads of control, a nonreentrant
program must be called only within interlocks.
The Bison parser is not normally a reentrant program, because it uses
statically allocated variables for communication with {fCode}yylex{f}. These
variables include {fCode}yylval{f} and {fCode}yylloc{f}.
The Bison declaration {fCode}%pure\_parser{f} says that you want the parser
to be reentrant. It looks like this:
#Wrap off
#fCode
%pure\_parser
#f
#Wrap on
The effect is that the two communication variables become local
variables in {fCode}yyparse{f}, and a different calling convention is used
for the lexical analyzer function {fCode}yylex{f}. \*Note <Pure Calling=>PureCallin>: Calling Conventions for Pure Parsers, for the details of this. The
variable {fCode}yynerrs{f} also becomes local in {fCode}yyparse{f}
(\*Note <Error Reporting=>ErrorRepor>: The Error Reporting Function {fCode}yyerror{f}).
The convention for calling {fCode}yyparse{f} itself is unchanged.